Skip to content

flight-cli: decompose cli.py monolith (safe pass) + unify the weaves (work-ai0jn.1/.2)#33

Open
ak2k wants to merge 9 commits into
mainfrom
worktree-cli-cleanup
Open

flight-cli: decompose cli.py monolith (safe pass) + unify the weaves (work-ai0jn.1/.2)#33
ak2k wants to merge 9 commits into
mainfrom
worktree-cli-cleanup

Conversation

@ak2k

@ak2k ak2k commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

Decomposes the 3,172-LOC cli.py monolith into 7 focused modules (safe pass — behavior-preserving) and unifies the two GF+Matrix concurrent weaves, closing the search-weave isolation gap. Closes work-ai0jn.1; delivers phase 1 of work-ai0jn.2.

What changed

  • 7 new modules — definitions moved out, imported back into cli.py: _console, _parsing, _runtime_opts, _dispatch, _urls, _pp_glue, _render (the big one, 500 LOC). cli.py 3,172 → 1,975 LOC. The weaves, orchestration, and command defs stay in cli.py (deferred to phase 2).
  • Weave-unify (closes work-ai0jn.1) — a shared _matrix_into_state dual-catch helper (MatrixApiError → matrix_err; Exception → matrix_unexpected) that both weaves route through, closing the search weave's non-MatrixApiError isolation gap (a raw transport error could previously escape the task group, cancel the GF paint, and traceback). Search post-run now reports matrix_unexpected, mirroring the calendar path.

Behavior preservation

  • 8 per-module commits, make check green after each (ruff + ruff format --check + basedpyright strict + pytest).
  • 509 tests — the 7 extractions are pure moves with zero test-file edits; +1 new regression test (test_search_weave.py) that would traceback against the pre-fix code.
  • Live-smoked: flight airport + the full flight search JFK LHR path (GF table → …refining with Matrix… → merged GF+Matrix repaint) render identically to main.

Convention (documented # DIVERGE)

Extracted modules expose public names; cli.py re-imports them under underscore aliases (from ._render import render_search as _render_search) so flight_cli.cli.X stays resolvable for the test suite's imports + monkeypatch.setattr(cli, …). This is a suppression-free convention matching the repo's existing merge as _merge_cabins pattern; it converges in phase 2 (once orchestration leaves cli.py, tests patch the submodules directly per the _gf_dategrid/_calendar_split precedent).

Review

ce-code-review (correctness · architecture · maintainability · project-standards): correctness clean; all other findings P2/P3, deferred to phase 2 and tracked on work-ai0jn.2 — shim→submodule convergence, _run_*_orchestrate.py as the next seam, and a typed weave-outcome object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant